#if 0

#include <sys/timerfd.h>
#include <time.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>  // Definition of uint64_t

#define handle_error(msg) \
               do { perror(msg); exit(EXIT_FAILURE); } while (0)

void showTime()
{
	time_t timer;
	struct tm *tblock;
	timer = time(NULL);
	tblock = localtime(&timer);
	printf("Local time is: %s", asctime(tblock));
}

int main()
{	
	struct itimerspec value;
	struct timespec now;

	if(clock_gettime(CLOCK_REALTIME,&now) == -1)
		handle_error("clock_gettime");

	showTime();

	value.it_value.tv_sec = now.tv_sec + 3;
	value.it_value.tv_sec = now.tv_nsec;

	value.it_interval.tv_sec = 5;
	value.it_interval.tv_nsec = 0;

	int fd = timerfd_create(CLOCK_REALTIME, 0); // 构建了一个定时器
	if (fd == -1)
		handle_error("timerfd_create");

	if (timerfd_settime(fd, TFD_TIMER_ABSTIME, &value, NULL) == -1)
		handle_error("timerfd_settime");

	uint64_t exp;
	ssize_t s;
	while (1)
	{	
		printf("before read\n");
		s = read(fd, &exp, sizeof(uint64_t));//会阻塞在这里
		printf("after read\n");
		if (s != sizeof(uint64_t))
			handle_error("read");
	}
	getchar();
	exit(EXIT_SUCCESS);
	return 0;
}


#endif // 1